<template>
	<view class="homeLayout pageBg">
		<custom-nav-bar title='首页'></custom-nav-bar>

		
		
		<view class="banner">
			<swiper circular  autoplay>
				<swiper-item v-for="item in bannerList" :key="item.id">
					<image class="imgBn"   :src="item.img" mode="aspectFill"></image>
					
				</swiper-item>
			
			</swiper>
			
		</view>
		
		<view class="notice">
		
			<view class="dcType">
				<view class="left">
					<image src="../../static/cgsb.png" mode="aspectFill"></image>
				</view>
				
				<view class="right" @click="declare()">
				
						<view class="textUp">
							成果申报
						</view>
				
						<view class="textDown">
							透明公开 实时反馈
						</view>
					
				</view>
			</view>
			
			<view class="dcType">
				<view class="left">
					<image src="../../static/zlcx.png" mode="aspectFill"></image>
				</view>
				
				<view class="right" @click="search()">
					<view class="textUp">
						资料查询
					</view>
					
					<view class="textDown">
						方便快捷 真实迅速
					</view>
				</view>
			</view>
			
		</view>	
	
		<view class="select">
			<common-title>
				<template #name>
					今日快讯
				</template>
				<template #custom>
					<view class="date">
						<uni-icons type="calendar" size="30" color="#1ec0ff"></uni-icons>
						<view class="text">
								<uni-dateformat :date="Date.now()" format="M月dd日"></uni-dateformat>
						</view>
					</view>
				
				
				</template>
			</common-title>
			<view class="content">
				<scroll-view scroll-y show-scrollbar="false">
					
						<uni-list-chat :avatar-circle="true" title="农大是我家" avatar="https://xinxinkc.online/static/upload/image/20241128/3f17b3d5b79a2206056644f1178bf2bb.png" note="欢迎你加入华农经管学院" time="2020-02-02 20:20" link to="/pages/notice/detail" v-for="(item,index) in 10" :key="index"></uni-list-chat>
					
				</scroll-view>
					
				
			</view>
		</view>
		
		
		
		
		
		
	</view>
</template>

<script setup>
	import {ref} from "vue";
    import {apiGetBanner,apiGetNotice,apiGetClassfy,apiUserInfo} from "../../api/apis";
	import {onShareAppMessage,onShareTimeline,onLoad,onShow} from "@dcloudio/uni-app";

	const bannerList =ref([]);
	const tjList = ref([]);
	const choiceList = ref([]);
	const noticeList = ref([]);
	const storClassList = ref([]);
	// const phone = ref(null);
	const picPopup = ref(null);
	const picDetailItem = ref({});
	
	
	onShow(async()=>{
		let userInfo =uni.getStorageSync('userInfo');
		if(userInfo){
			
			//请求接口获取数据
			let data ={
				id:userInfo.id,
				token:userInfo.token
			}
			let res = await apiUserInfo(data);
			
			// phone.value =res.data.username; 
			tjList.value = res.data.tjList;
			choiceList.value = res.data.jxList;
			if(userInfo.lv<1){
				uni.switchTab({
					url:"/pages/user/user"
				})
			}
		}else{
			//去登录
			uni.navigateTo({
				url:"/pages/user/login"
			})
		}
	})
	

	
	const getBanner = async ()=>{
		let res= await apiGetBanner();
		
		bannerList.value = res.data;
	
	}
	
	//图片详情弹窗
	const imgDetail = (item)=>{
		picDetailItem.value = item;
		
		picPopup.value.open();
	
	}
	
	
	
	const getNotice = async ()=>{
		let res= await apiGetNotice();
		noticeList.value = res.data;
	}
	
	//查询
	const search = ()=>{
		
		uni.switchTab({
			url:"/pages/order/order"
		})
	}
	
	//申报
	const declare = ()=>{
		uni.navigateTo({
			url:"/pages/teacher/declare"
		})
		
	}
	
	//分享好友
	onShareAppMessage((e) =>{
		return {
			title:"华农经管学院",
			path:"/pages/index/index",
			imageUrl:bannerList.value[0].picurl
		}
	})
	//分享朋友圈
	onShareTimeline(()=>{
		return {
			title:"华农经管学院",
			path:"/pages/index/index",
			imageUrl:bannerList.value[0].picurl
		}
	})
	
	getBanner();
	// getTj();
	// getNotice();
	// getClassfy();
	
	
</script>

<style lang='scss' scoped>

.homeLayout{

	.text{
		padding:30rpx 30rpx;
		.good{
			font-size: 52rpx;
			
			font-weight: 600;
		}
		.header{
			
		}
		.date{
			font-size: 28rpx;
		}
	}
	.banner{
		width:750rpx;
		padding:30rpx 0;
		
		swiper{
			width:750rpx;
			height: 350rpx;
			
			swiper-item{
				width: 100%;
				height: 100%;
				padding:0 30rpx;
				
				.imgBn{
					width:100%;
					height:100%;
					border-radius: 20rpx;
				}
			}
		}
		
	}
	
	.notice{
		width: 690rpx;
		height: 200rpx;
		background-color: $uni-bg-color-grey;
		margin: 0 auto;
		border-radius: 20rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		
		.dcType{
			display: flex;
			
			justify-content: space-between;
			background: $xx-color-body;
			width:325rpx;
			height:200rpx;
			border-radius: 20rpx;
			image{
				width: 100rpx;
				height : 100rpx;
				
			}
			.left{
				margin-top: 80rpx;
				padding-left: 10rpx;
			}
			
			.right{
				color:#fff;
				margin-top: 10rpx;
				margin-right: 10rpx;
				.textUp{
					
					font-size: 40rpx;
					font-weight: 600;
					
				}
				
				.textDown{
					font-size: 24rpx;
					font-weight: 100;
				}
			}
		}
		
		
	}
	
	.select{
		padding-top: 50rpx;
		.content{
			width: 720rpx;
			margin-left: 30rpx;
			margin-top: 30rpx;
			scroll-view{
				height: 38vh;
				
			
			}
		}
		
		.date{
			color:#1ec0ff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			.text{
				margin-left: 5rpx;
			}
		}
	}
	
	.theme{
		padding: 50rpx 0;
		.more{
			font-size: 32rpx;
			color: #666;
		}
		.content{
			margin-top: 50rpx;
			padding: 0 30rpx;
			display: grid;
			gap:15rpx;
			grid-template-columns: repeat(3,1fr);
		}
	}
}
		
	
		
	
	
</style>
